package com.yanqu.road.entity.activity.gashapon.data;

import com.yanqu.road.entity.DataObject;
import com.yanqu.road.entity.FieldTypeAnnotation;

import java.util.HashMap;
import java.util.Map;

/**
 * @Author : Cxp
 * @Time : 2024-10-21
 * @Description : 幸运扭蛋-用户实体类
 */

@FieldTypeAnnotation(tableName = "t_u_gashapon_data")
public class GashaponUserData extends DataObject {
    @FieldTypeAnnotation(desc = "活动ID", select = true, update = true)
    private int activityId;

    @FieldTypeAnnotation(desc = "用户ID", select = true, update = true)
    private long userId;

    @FieldTypeAnnotation(desc = "个人总积分")
    private long score;

    @FieldTypeAnnotation(desc = "保底累计")
    private int guaranteeCnt;

    @FieldTypeAnnotation(desc = "当前局极品保底目标")
    private int excellentTarget;

    @FieldTypeAnnotation(desc = "当前局极品保底累计")
    private int excellentCnt;

    @FieldTypeAnnotation(desc = "抽取总计")
    private int drawCnt;

    @FieldTypeAnnotation(desc = "是否锁定当前轮")
    private boolean isLock;

    @FieldTypeAnnotation(desc = "当前轮是否播放过动画")
    private boolean isAnima;

    @FieldTypeAnnotation(desc = "单局已选奖励")
    private Map<Integer, Map<Integer, Integer>> choose;

    @FieldTypeAnnotation(desc = "全局已选奖励")
    private Map<Integer, Map<Integer, Integer>> optional;

    @FieldTypeAnnotation(desc = "单局已抽奖励")
    private Map<Integer, Map<Integer, Integer>> selected;

    public int getActivityId() {
        return activityId;
    }

    public void setActivityId(int activityId) {
        if (this.activityId != activityId) {
            this.activityId = activityId;
            setUpdateOption();
        }
    }

    public long getUserId() {
        return userId;
    }

    public void setUserId(long userId) {
        if (this.userId != userId) {
            this.userId = userId;
            setUpdateOption();
        }
    }

    public long getScore() {
        return score;
    }

    public void setScore(long score) {
        if (this.score != score) {
            this.score = score;
            setUpdateOption();
        }
    }

    public int getGuaranteeCnt() {
        return guaranteeCnt;
    }

    public void setGuaranteeCnt(int guaranteeCnt) {
        if (this.guaranteeCnt != guaranteeCnt) {
            this.guaranteeCnt = guaranteeCnt;
            setUpdateOption();
        }
    }

    public int getExcellentTarget() {
        return excellentTarget;
    }

    public void setExcellentTarget(int excellentTarget) {
        if (this.excellentTarget != excellentTarget) {
            this.excellentTarget = excellentTarget;
            setUpdateOption();
        }
    }

    public int getExcellentCnt() {
        return excellentCnt;
    }

    public void setExcellentCnt(int excellentCnt) {
        if (this.excellentCnt != excellentCnt) {
            this.excellentCnt = excellentCnt;
            setUpdateOption();
        }
    }

    public int getDrawCnt() {
        return drawCnt;
    }

    public void setDrawCnt(int drawCnt) {
        if (this.drawCnt != drawCnt) {
            this.drawCnt = drawCnt;
            setUpdateOption();
        }
    }

    public boolean isLock() {
        return isLock;
    }

    public void setLock(boolean lock) {
        if (this.isLock != lock) {
            this.isLock = lock;
            setUpdateOption();
        }
    }

    public boolean isAnima() {
        return isAnima;
    }

    public void setAnima(boolean anima) {
        if (this.isAnima != anima) {
            this.isAnima = anima;
            setUpdateOption();
        }
    }

    public Map<Integer, Map<Integer, Integer>> getChoose() {
        if (choose == null) {
            return new HashMap<>();
        }
        return choose;
    }

    public void setChoose(Map<Integer, Map<Integer, Integer>> choose) {
        if (this.choose != choose) {
            this.choose = choose;
            setUpdateOption();
        }
    }

    public Map<Integer, Map<Integer, Integer>> getOptional() {
        if (optional == null) {
            return new HashMap<>();
        }
        return optional;
    }

    public void setOptional(Map<Integer, Map<Integer, Integer>> optional) {
        if (this.optional != optional) {
            this.optional = optional;
            setUpdateOption();
        }
    }

    public Map<Integer, Map<Integer, Integer>> getSelected() {
        if (selected == null) {
            return new HashMap<>();
        }
        return selected;
    }

    public void setSelected(Map<Integer, Map<Integer, Integer>> selected) {
        if (this.selected != selected) {
            this.selected = selected;
            setUpdateOption();
        }
    }

    public GashaponUserData clone() {
        GashaponUserData res = new GashaponUserData();

        res.setActivityId(this.getActivityId());
        res.setUserId(this.getUserId());
        res.setScore(this.getScore());
        res.setGuaranteeCnt(this.getGuaranteeCnt());
        res.setExcellentTarget(this.getExcellentTarget());
        res.setExcellentCnt(this.getExcellentCnt());
        res.setDrawCnt(this.getDrawCnt());
        res.setLock(this.isLock());
        res.setAnima(this.isAnima());
        Map<Integer, Map<Integer, Integer>> tmpChoose = new HashMap<>();
        for (Map.Entry<Integer, Map<Integer, Integer>> kv : this.getChoose().entrySet()) {
            int key = kv.getKey();
            if (!tmpChoose.containsKey(key)) {
                tmpChoose.put(key, new HashMap<>(kv.getValue()));
            }
        }
        res.setChoose(tmpChoose);

        Map<Integer, Map<Integer, Integer>> tmpOptional = new HashMap<>();
        for (Map.Entry<Integer, Map<Integer, Integer>> kv : this.getOptional().entrySet()) {
            int key = kv.getKey();
            if (!tmpOptional.containsKey(key)) {
                tmpOptional.put(key, new HashMap<>(kv.getValue()));
            }
        }
        res.setOptional(tmpOptional);

        Map<Integer, Map<Integer, Integer>> tmpSelected = new HashMap<>();
        for (Map.Entry<Integer, Map<Integer, Integer>> kv : this.getSelected().entrySet()) {
            int key = kv.getKey();
            if (!tmpSelected.containsKey(key)) {
                tmpSelected.put(key, new HashMap<>(kv.getValue()));
            }
        }
        res.setSelected(tmpSelected);

        return res;
    }

    public void copy(GashaponUserData data) {
        this.setActivityId(data.getActivityId());
        this.setUserId(data.getUserId());
        this.setScore(data.getScore());
        this.setGuaranteeCnt(data.getGuaranteeCnt());
        this.setExcellentTarget(data.getExcellentTarget());
        this.setExcellentCnt(data.getExcellentCnt());
        this.setDrawCnt(data.getDrawCnt());
        this.setLock(data.isLock());
        this.setAnima(data.isAnima());
        this.setChoose(data.getChoose());
        this.setOptional(data.getOptional());
        this.setSelected(data.getSelected());

        setUpdateOption();
    }
}
